package com.gt.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gt.admin.domain.QuestionnaireCalculateDetail;
import com.gt.admin.domain.QuestionnaireManage;
import com.gt.admin.domain.vo.QuestionnaireCalculateDetailVO;
import com.gt.admin.mapper.QuestionnaireCalculateDetailMapper;
import com.gt.admin.mapper.QuestionnaireManageMapper;
import com.gt.admin.service.IQuestionnaireCalculateDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class QuestionnaireCalculateDetailServiceImpl extends ServiceImpl<QuestionnaireCalculateDetailMapper, QuestionnaireCalculateDetail> implements IQuestionnaireCalculateDetailService {
    @Autowired
    QuestionnaireCalculateDetailMapper questionnaireCalculateDetailMapper;
    @Autowired
    QuestionnaireManageMapper questionnaireManageMapper;

    /**
     * 审核说明
     * @param queId
     * @return
     */
    @Override
    public QuestionnaireCalculateDetailVO list(Long queId) {
        QuestionnaireManage questionnaireManage = questionnaireManageMapper.selectById(queId);
        QuestionnaireCalculateDetailVO detailVO = QuestionnaireCalculateDetailVO.builder()
                .queId(queId)
                .name(questionnaireManage.getName())
                .sex(questionnaireManage.getSex())
                .age(questionnaireManage.getAge())
                .assessResult(questionnaireManage.getAssessResult())
                .address(questionnaireManage.getAddress())
                .queStatus(questionnaireManage.getQueStatus())
                .build();
        LambdaQueryWrapper<QuestionnaireCalculateDetail> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(QuestionnaireCalculateDetail::getQueId, queId);
        List<QuestionnaireCalculateDetail> detailList = list(queryWrapper);
        detailVO.setQuestionnaireCalculateDetailList(detailList);
        return detailVO;
    }
}
